#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void obnulenie(int a[], int n)
{
int i;
for (i = 0; i < n; i ++)
	a[i]=0;
}

void main()
{
	int n, step, thrown, index, counter;
	int mass[100000];
	
	printf("vvedite col-vo igrokov\n");
	scanf("%d", &n);
	printf("\n");

	printf("vvedite shag vubrosa\n");
	scanf("%d", &step);
	printf("\n");

	step = step %n;

	obnulenie(mass,n);

	index = 0;
	counter = 0;
	thrown = 0;
	
	
	while (true) {
		while(counter < step) {
			if(mass[index] == 0) {
				counter++;
				if(counter < step) index = (index+1) % n;
			} else {
				index = (index+1) % n;
			}
		}
		mass[index] = 1;
		counter = 0;
		thrown++;

		if(thrown < n)
			printf("throw %d\n", index+1);
		else {
			printf("index %d wins\n", index+1);
			break;
		}
	}
system("pause");
}
